home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / QuickDraw / OffSample / OffSample.r < prev    next >
Encoding:
Text File  |  1994-11-18  |  7.2 KB  |  348 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    Offscreen Buffer Sample Application
  6. #
  7. #    OffSample
  8. #
  9. #    OffSample.r        -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                04/89
  16. #                1.01                06/92
  17. #
  18. #    Components:
  19. #                OffSample.p            April 1, 1989
  20. #                OffSample.r            April 1, 1989
  21. #                OffSample.h            April 1, 1989
  22. #                OffSample.rsrc        April 1, 1989
  23. #                POffSample.make        April 1, 1989
  24. #
  25. #    Requirements:
  26. #                Offscreen.p            April 1, 1989
  27. #                Offscreen.inc1.p    April 1, 1989
  28. #                UFailure.p            November 1, 1988
  29. #                UFailure.inc1.p        November 1, 1988
  30. #                UFailure.a            November 1, 1988
  31. #
  32. #    OffSample demonstrates the usage of the Offscreen
  33. #    unit. It shows how to use offscreen pixmaps and
  34. #    bitmaps to produce flicker-free updating with a
  35. #    minimum of re-structuring of code. OffSample attempts
  36. #    to reduce the amount of 'knowledge' that it has of
  37. #    the offscreen structure so as to minimize its
  38. #    dependence on that unit.
  39. #
  40. #    OffSample emphasizes using the Offscreen unit; it
  41. #    is not intended to be viewed as a complete application
  42. #    from which to base some larger effort. Instead, its
  43. #    method of using offscreen bitmaps and pixmaps should
  44. #    be studied and adapted to other applications that
  45. #    desire features such as flicker-free updating.
  46. #
  47. ------------------------------------------------------------------------------*/
  48.  
  49.  
  50. #include "Types.r"
  51.  
  52. #include "OffSample.h"
  53.  
  54. include "OffSample.rsrc";
  55.  
  56. /* we use an MBAR resource to conveniently load all the menus */
  57.  
  58. resource 'MBAR' (rMenuBar, preload) {
  59.     { mApple, mFile, mEdit, mShape, mSpecial };    /* five menus */
  60. };
  61.  
  62.  
  63. resource 'MENU' (mApple, preload) {
  64.     mApple, textMenuProc,
  65.     AllItems & ~MenuItem2,    /* Disable dashed line, enable About and DAs */
  66.     enabled, apple,
  67.     {
  68.         "About OffSample…",
  69.             noicon, nokey, nomark, plain;
  70.         "-",
  71.             noicon, nokey, nomark, plain
  72.     }
  73. };
  74.  
  75. resource 'MENU' (mFile, preload) {
  76.     mFile, textMenuProc,
  77.     MenuItem1 | MenuItem12,                /* enable New and Quit only, program enables others */
  78.     enabled, "File",
  79.     {
  80.         "New",
  81.             noicon, "N", nomark, plain;
  82.         "Open",
  83.             noicon, "O", nomark, plain;
  84.         "-",
  85.             noicon, nokey, nomark, plain;
  86.         "Close",
  87.             noicon, "W", nomark, plain;
  88.         "Save",
  89.             noicon, "S", nomark, plain;
  90.         "Save As…",
  91.             noicon, nokey, nomark, plain;
  92.         "Revert",
  93.             noicon, nokey, nomark, plain;
  94.         "-",
  95.             noicon, nokey, nomark, plain;
  96.         "Page Setup…",
  97.             noicon, nokey, nomark, plain;
  98.         "Print…",
  99.             noicon, nokey, nomark, plain;
  100.         "-",
  101.             noicon, nokey, nomark, plain;
  102.         "Quit",
  103.             noicon, "Q", nomark, plain
  104.     }
  105. };
  106.  
  107. resource 'MENU' (mEdit, preload) {
  108.     mEdit, textMenuProc,
  109.     NoItems,                /* disable everything, program does the enabling */
  110.     enabled, "Edit",
  111.      {
  112.         "Undo",
  113.             noicon, "Z", nomark, plain;
  114.         "-",
  115.             noicon, nokey, nomark, plain;
  116.         "Cut",
  117.             noicon, "X", nomark, plain;
  118.         "Copy",
  119.             noicon, "C", nomark, plain;
  120.         "Paste",
  121.             noicon, "V", nomark, plain;
  122.         "Clear",
  123.             noicon, nokey, nomark, plain
  124.     }
  125. };
  126.  
  127. resource 'MENU' (mShape, preload) {
  128.     mShape, textMenuProc,
  129.     AllItems,                /* Enable all */
  130.     enabled, "Shapes",
  131.     {
  132.         "Oval",
  133.             noicon, nokey, check, plain;
  134.         "Region",
  135.             noicon, nokey, nomark, plain;
  136.         "RoundRect",
  137.             noicon, nokey, nomark, plain;
  138.         "Polygon",
  139.             noicon, nokey, nomark, plain;
  140.         "Rect",
  141.             noicon, nokey, nomark, plain;
  142.         "Moof!™",
  143.             noicon, nokey, nomark, plain;
  144.         "Gigantor",
  145.             noicon, nokey, nomark, plain
  146.     }
  147. };
  148.  
  149. resource 'MENU' (mSpecial, preload) {
  150.     mSpecial, textMenuProc,
  151.     AllItems & ~MenuItem3,    /* Disable dashed line */
  152.     enabled, "Special",
  153.     {
  154.         "Attempt Background Buffer",
  155.             noicon, nokey, check, plain;
  156.         "Attempt Foreground Buffer",
  157.             noicon, nokey, check, plain;
  158.         "-",
  159.             noicon, nokey, nomark, plain;
  160.         "Pick Object Color…",
  161.             noicon, nokey, nomark, plain
  162.     }
  163. };
  164.  
  165.  
  166. /* this ALRT and DITL are used as an About screen */
  167.  
  168. resource 'ALRT' (rAboutAlert, purgeable) {
  169.     {40, 20, 160, 290},
  170.     rAboutAlert,
  171.     { /* array: 4 elements */
  172.         /* [1] */
  173.         OK, visible, silent,
  174.         /* [2] */
  175.         OK, visible, silent,
  176.         /* [3] */
  177.         OK, visible, silent,
  178.         /* [4] */
  179.         OK, visible, silent
  180.     }
  181. };
  182.  
  183. resource 'DITL' (rAboutAlert, purgeable) {
  184.     { /* array DITLarray: 5 elements */
  185.         /* [1] */
  186.         {88, 180, 108, 260},
  187.         Button {
  188.             enabled,
  189.             "OK"
  190.         },
  191.         /* [2] */
  192.         {8, 8, 24, 214},
  193.         StaticText {
  194.             disabled,
  195.             "Offscreen Sample"
  196.         },
  197.         /* [3] */
  198.         {32, 8, 48, 237},
  199.         StaticText {
  200.             disabled,
  201.             "Copyright © 1989 Apple Computer"
  202.         },
  203.         /* [4] */
  204.         {56, 8, 72, 136},
  205.         StaticText {
  206.             disabled,
  207.             "Brought to you by:"
  208.         },
  209.         /* [5] */
  210.         {80, 24, 112, 167},
  211.         StaticText {
  212.             disabled,
  213.             "Macintosh Developer  Technical Support"
  214.         }
  215.     }
  216. };
  217.  
  218.  
  219. /* this ALRT and DITL are used as an error screen */
  220.  
  221. resource 'ALRT' (rUserAlert, purgeable) {
  222.     {40, 20, 180, 260},
  223.     rUserAlert,
  224.     { /* array: 4 elements */
  225.         /* [1] */
  226.         OK, visible, silent,
  227.         /* [2] */
  228.         OK, visible, silent,
  229.         /* [3] */
  230.         OK, visible, silent,
  231.         /* [4] */
  232.         OK, visible, silent
  233.     }
  234. };
  235.  
  236.  
  237. resource 'DITL' (rUserAlert, purgeable) {
  238.     { /* array DITLarray: 4 elements */
  239.         /* [1] */
  240.         {110, 150, 130, 230},
  241.         Button {
  242.             enabled,
  243.             "OK"
  244.         },
  245.         /* [2] */
  246.         {10, 60, 60, 230},
  247.         StaticText {
  248.             disabled,
  249.             "OffSample error. ^0."
  250.         },
  251.         /* [3] */
  252.         {70, 60, 90, 230},
  253.         StaticText {
  254.             disabled,
  255.             "^1"
  256.         },
  257.         /* [4] */
  258.         {8, 8, 40, 40},
  259.         Icon {
  260.             disabled,
  261.             2
  262.         }
  263.     }
  264. };
  265.  
  266.  
  267. resource 'STR#' (sErrStrings, purgeable) {
  268.     {
  269.     "An error occurred. The error number is: ";
  270.     "You must run on 512Ke or later";
  271.     "Application Memory Size is too small";
  272.     "Not enough memory to run OffSample";
  273.     }
  274. };
  275.  
  276.  
  277. resource 'STR ' (kNoBackBuff, purgeable) {
  278.     " / BackDealloc"
  279. };
  280.  
  281. resource 'STR ' (kNoEditBuff, purgeable) {
  282.     " / EditDeAlloc"
  283. };
  284.  
  285. resource 'STR ' (kTitle, purgeable) {
  286.     "Offscreen"
  287. };
  288.  
  289. resource 'STR ' (kColorPrompt, purgeable) {
  290.     "Select shape color."
  291. };
  292.  
  293. resource 'STR ' (kNoWantBack, purgeable) {
  294.     " / BackDenied"
  295. };
  296.  
  297. resource 'STR ' (kNoWantEdit, purgeable) {
  298.     " / EditDenied"
  299. };
  300.  
  301.  
  302. resource 'WIND' (rWindow, preload, purgeable) {
  303.     {60, 40, 290, 360},
  304.     noGrowDocProc, visible, goAway, 0x0, " "
  305. };
  306.  
  307.  
  308. resource 'pltt' (rWindow) {
  309.     {
  310.         0x0, 0x0, 0x0, pmTolerant, 0x0000,                /* Black */
  311.         0xFFFF, 0xFFFF, 0xFFFF, pmTolerant, 0x0000,        /* White */
  312.         0xFFFF, 0x0, 0x0, pmTolerant, 0x0000,            /* Oval's starting color    */
  313.         0x0, 0x0, 0xFFFF, pmTolerant, 0x0000,            /* Rgn's    "        "        */
  314.         0x9999, 0x6666, 0x0, pmTolerant, 0x0000,        /* RRect's    "        "        */
  315.         0x6666, 0x0, 0x9999, pmTolerant, 0x0000,        /* Poly's    "        "        */
  316.         0xCCCC, 0xCCCC, 0xCCCC, pmTolerant, 0x0000,        /* Rect's    "        "        */
  317.     }
  318. };
  319.  
  320.  
  321. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  322.  
  323. resource 'SIZE' (-1) {
  324.     dontSaveScreen,
  325.     acceptSuspendResumeEvents,
  326.     enableOptionSwitch,
  327.     canBackground,                /* we can background; we don't currently, but our */
  328.                                 /* sleep value guarantees we don't hog the Mac while */
  329.                                 /* we are in the background */
  330.     multiFinderAware,            /* this says we do our own activate/deactivate; don't */
  331.                                 /* fake us out */
  332.     backgroundAndForeground,    /* this is definitely not a background-only */
  333.                                 /* application! */
  334.     dontGetFrontClicks,            /* change this is if you want "do first click" */
  335.                                 /* behavior like the Finder */
  336.     ignoreChildDiedEvents,
  337.     is32BitCompatible,
  338.     reserved,
  339.     reserved,
  340.     reserved,
  341.     reserved,
  342.     reserved,
  343.     reserved,
  344.     reserved,
  345.     kPrefSize * 1024,
  346.     kMinSize * 1024    
  347. };
  348.